package installer.attention;

import java.io.IOException;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;

public class InstallFansTable {
	private static JdbcTemplate jdbcTemplate;

	@BeforeClass
	public static void before() {
		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				"config/context/applicationContext.xml");
		jdbcTemplate = (JdbcTemplate) ctx.getBean("jdbcTemplate");
	}

	@Test
	public void install() throws DataAccessException, IOException {
		// 创建表
		try {
			String sql = "CREATE TABLE fans (fbid  bigint PRIMARY KEY AUTO_INCREMENT,idolId  bigint NOT NULL ,idolNickname  varchar(60) NOT NULL ,idolPortrait  varchar(40) NOT NULL ,fanId  bigint NOT NULL ,fanNickname  varchar(60) NOT NULL ,fanPortrait  varchar(40) NOT NULL ,activity enum('normal','frozen','deleted','undeletable') default 'normal' ,idolType enum('user','viewPoint') not null  ,createTime  datetime NOT NULL );";
			jdbcTemplate.update(sql);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
